﻿// screenshot_dui.cpp : 定义应用程序的入口点。
//

#include "framework.h"
#include "screenshot_dui.h"

#include "screenshotwnd.h"

void SetSkinPath(HINSTANCE hInstance)
{
  DuiLib::CPaintManagerUI::SetInstance(hInstance);

  TCHAR szPath[MAX_PATH] = { 0 };
  GetModuleFileName(NULL, szPath, sizeof(szPath));
  PathRemoveFileSpec(szPath);
  PathCombine(szPath, szPath, L"res");

  DuiLib::CPaintManagerUI::SetResourcePath(szPath);
}

int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
                     _In_opt_ HINSTANCE hPrevInstance,
                     _In_ LPWSTR    lpCmdLine,
                     _In_ int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

    int retValue = 0;
    
    CoInitialize(NULL);

    // 初始化GDI+
    GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

    SetSkinPath(hInstance);

    ScreenshotWnd wnd;
    RECT rc = { 0,0,0,0 };
    wnd.Create(NULL, L"", UI_WNDSTYLE_DIALOG & (~WS_VISIBLE), NULL, rc);
    wnd.CenterWindow();
    /*retValue = */wnd.ShowWindow(FALSE);
    wnd.GetPaintManager()->MessageLoop();

    GdiplusShutdown(gdiplusToken);
    CoUninitialize();
    return (int)retValue;
}
